<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
   
<title>个人资料</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/common.js"></script>

</head>
<script type="text/javascript">
// 屏蔽屏幕自身手势
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
var storage = window.localStorage;
var currRole = getUrlParam("currRole");
var isMainRole = getUrlParam("isMainRole");
var sex;
$(document).ready(function() {
	var userCode = storage.getItem("primaryRole");
/* 	if(userCode==''){
		alert("请重新登录");
		window.location.href = "./jsp/login.jsp";
	}else{
		$("#userName").html(userName);
	} */
	$.ajax({
       url: "./user/currRole",
       type: "POST",
       data:{
			currRole : currRole,
			isMainRole : isMainRole
		},
       dataType: 'json',
       cache: false,
       success: function (ret) {
    	   	if (ret.resultCode==0) {
    	   		if(isMainRole==0){
    	   			$("#realName").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ret.content.userName);
    	   			$("#phone").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;未设置");
    	   		}else{
    	   			$("#phone").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ret.content.phone);
    	   			$("#realName").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+(ret.content.realName==null?"未设置":ret.content.realName));
    	   		}
    	   		sex = ret.content.sex;
				$("#userName").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ret.content.userName);
				
				$("#realphone").html("&nbsp;&nbsp;"+ret.content.phone);
				$("#sex").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+(ret.content.sex==0?"男":"女"));
				$("#birth").val(getSmpFormatDateByLong(ret.content.birth,false));
          	}
       }
   });
});
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return  decodeURI(r[2]); return null;
}

function setPwd(){
	$("#pwdtext").show();
}

function setsex(){
	$("#sex").hide();
	$("#sexselect").show();
}

function setName(){
	$("#realName").hide();
	$("#realNametext").show();
}

function save(){
	var name = $("#realNametext").val()?$("#realNametext").val():$("#realName").val();
	if($("#sexselect").css("display")!="none"){
		sex = $("#sexselect").find("option:selected").val();
	}
	var birth = $("#birth").val();
	$.ajax({
       url: "./user/editUser",
       type: "POST",
       data:{
			currRole : currRole,
			isMainRole : isMainRole,
			name : name,
			sex : sex,
			birth : birth
		},
       dataType: 'json',
       cache: false,
       success: function (ret) {
    	   	if (ret.resultCode==0) {
    	   		window.location.reload(); 
          	}
       	}
   	});
}
</script>
  
<body ontouchstart>
<div class="container js_container">
  </div>
  
  <div class="weui_cells weui_cells_access">
      <a class="weui_cell" href="javascript:;">
          <div class="weui_cell_hd">
       	  </div>
          <div class="weui_cell_bd weui_cell_primary">
              <p id="userName">-</p>
          </div>
          <div >
          <img src="./images/example.jpg" alt="" style="width:50px;height:50px; display:block;">
          </div>
      </a>
  </div>
    <div class="weui_cells">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>帐&nbsp;号
                    	<span id="phone"></span>
                   	</p>
                </div>
                <div class="weui_cell_ft"></div>
            </div>
             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" onclick="setName()">
                    <p>姓&nbsp;名
                    	<span id="realName"></span>
                    	<input class="weui_input" type="text" style="display: none;width:70%;" id="realNametext">
                    </p>
                </div>
                <div class="weui_cell_ft"></div>
        </div>
        <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" onclick="setsex()"> 
                    <p>性&nbsp;别
                    	<span id="sex"></span>
                    	<select style="display: none;width:70%;" id="sexselect">
                    		<option value="0">男</option>
                    		<option value="1">女</option>
                    	</select>
                   	</p>
                </div>
                <div class="weui_cell_ft"></div>
            </div>
<!--             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>邮箱</p>
                </div>
                <div class="weui_cell_ft">未设置</div>
            </div> -->
<!--             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" >
                    <p>手机号
                    	<span id="realphone"></span>
                   	</p>
                </div>
                <div class="weui_cell_ft"></div>
            </div> -->
<!--             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>身份证号码</p>
                </div>
                <div class="weui_cell_ft">未设置</div>
            </div> -->
  			<div class="weui_cell">
                <div class="weui_cell_hd"><label for="" class="weui_label" style="width: 5em">出生日期</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="date" value="" id="birth">
                </div>
            </div>
<!--             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>常住地</p>
                </div>
                <div class="weui_cell_ft">未设置</div>
            </div> -->
<!--             <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary" onclick="setPwd()">
                    <p>修改密码
                    	<input class="weui_input" type="text" style="display: none;width:50%;" id="pwdtext">
                    </p>
                </div>
                <div class="weui_cell_ft"></div>
            </div> -->
<!--             <a class="weui_cell" href="javascript:;">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>绑定第三方帐号</p>
                </div>
                <div class="weui_cell_ft">
                </div>
            </a> -->
        </div>
		<footer style="position: fixed;bottom: 1px;width: 100%;">
  			<a class="weui_btn" style="color:#fff;background-color: #337ab7;" onclick="save()">保存</a>
		</footer> 
</body>
</html>
